<div class="pager" id="pager"><?php
    /* @var $Pager Pager */
    $pages = $pager->getPages();
    $page = $pager->getPageNumber();

    if($pages > 1) {
        echo '<span>Страниц ('.$pages.'):</span>&nbsp;';  
           
        $min=$page-6;
        $max=$page+8;

        if ($min<1) { $min=1; }
        if ($max>$pages) { $max=$pages;}
       
        if ($min>1) {
            echo "&nbsp;<a href='?page=".($min-1)."'> ...</a>&nbsp;";
        }
       
        for ($i=$min; $i<=$max; $i++)          
        {
            if ($i == $page) {            
                echo "&nbsp;<b>".$i."</b>&nbsp;";          
            }
            else {
                echo "&nbsp;<a href='?page=".$i."'>".$i."</a>&nbsp;";  
            }
        }
        if ($max<$pages) {
            echo "&nbsp;<a href='?page=".($max+1)."'>...</a>&nbsp;";
        }
        
        echo "<br/>";
        
        if ($min>1) {
            echo "<small><a href='?page=1'>&larr;первая</a></small> ";
        }
        if ($max<$pages) {
            echo "<small><a href='?page=".$pages."'> последняя&rarr;</a></small>";
        }
    }
?></div>